package com.zhanglingfei.yuekaoshop.entity;

import lombok.Data;

import java.io.Serializable;

import javax.persistence.*;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * @author Shichao.Lu
 * sku表,该表表示具体的商品实体,如黑色的 64g的iphone 8
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@Entity
@Table(name = "tb_sku")
@DynamicInsert
@DynamicUpdate
public class Sku implements Serializable {

	/**
	 * sku id
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id")
	private Long id;

	/**
	 * spu id
	 */
	@Column(name = "spu_id")
	private Long spuId;

	/**
	 * 商品标题
	 */
	@Column(name = "title")
	private String title;

	/**
	 * 商品的图片，多个图片以‘,’分割
	 */
	@Column(name = "images")
	private String images;

	/**
	 * 销售价格，单位为分
	 */
	@Column(name = "price")
	private Long price;

	/**
	 * 特有规格属性在spu属性模板中的对应下标组合
	 */
	@Column(name = "indexes")
	private String indexes;

	/**
	 * sku的特有规格参数键值对，json格式，反序列化时请使用linkedHashMap，保证有序
	 */
	@Column(name = "own_spec")
	private String ownSpec;

	/**
	 * 是否有效，0无效，1有效
	 */
	@Column(name = "enable")
	private Boolean enable;

	/**
	 * 添加时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "create_time")
	private java.util.Date createTime;

	/**
	 * 最后修改时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "last_update_time")
	private java.util.Date lastUpdateTime;
}
